<include file="public:header" />
<div class="subnav">
	<div class="content_menu ib_a blue line_x">
    		注意：本采集器需要对接爱淘客联盟，未购买授权请联系我们 <a href="http://bbs.itaoke.org/" target="_blank">http://bbs.itaoke.org/</a>
	</div>
</div>
<div class="subnav">
	<h1 class="title_2 line_x">爱淘宝联盟优惠券采集器</h1>
</div>
<div class="pad_lr_10">
    <form id="J_info_form" action="{:U('Quancaiji/setting')}" method="post">
    <table width="100%" cellspacing="0" class="table_form">
	<tr>
		<th width="150">爱淘客联盟优惠券分类 :</th>
		<td>
			<select name="cat" id="union_cats">
				<option value="0">--请选择--</option>
			</select>
			<span class="red ml10">留空代表采集全部。</span>
		</td>
	</tr>
	<tr>
		<th width="150">入库分类 :</th>
		<td>
			<select class="J_cate_select mr10" data-pid="0" data-uri="{:U('ItemsCate/ajax_getchilds', array('type'=>0))}"></select>
			<span class="red ml10">请选择采集后要写入的分类,可不选。</span>
		</td>			
        </tr>
	<tr>
          <th>最低佣金 :</th>
          <td>
		  <input type="text" name="mincommission" size="8" class="input-text" value="0"/>
		  <span class="red ml10">(%)采集最低佣金; 0 表示不限制</span>
		  </td>
    </tr>        
	<tr>
		<th width="150">共采集多少页 :</th>
		<td>
			<input name="num" type="text" class="input-text" size="8" value="30"/>
			<span class="red ml10">数量越小采集速度越快，默认每页50 个优惠券 ！</span>我们的产品库：<a href="http://www.aitaoker.com/" target="_blank">http://www.aitaoker.com/</a>
		</td>
	</tr>	
        <tr>
		<th></th>
		<td><input type="submit" value="开始采集" name="dosubmit" class="smt mr10"></td>
	</tr>
    </table>
    <input type="hidden" name="cate_id" id="J_cate_id" value="0" />	
    </form>	
</div>
<include file="public:footer" />
<script>
$(function(){
    var collect_url = "{:U('Quancaiji/collect')}";
    $('#J_info_form').ajaxForm({success:complete, dataType:'json'});
    var p = 2;
    function complete(result){
        if(result.status == 1){
            $.dialog({id:'quancaiji', title:result.msg, content:result.data, padding:'', lock:true});
            p = 2;
            collect_page();
        } else {
            $.itaoke.tip({content:result.msg, icon:'alert'});
        }
    }
    function collect_page(){
        $.getJSON(collect_url, {p:p}, function(result){
            if(result.status == 1){
                $.dialog.get('quancaiji').content(result.data);
                p++;
                collect_page(p);
            }else{
                $.dialog.get('quancaiji').close();
                $.itaoke.tip({content:result.msg});
            }
        });
    }
   $('.J_cate_select').cate_select({field:'J_cate_id'});
   
    var cats_url="{:U('Quancaiji/getUnionCats')}";
    $.ajax(cats_url, {
        type: 'post',
        dataType: 'json',
        success: function(data){
       	 if(data.status==0){
        	var res=data.data;
			for(var i=0;i<res.length;i++){
				$("#union_cats").append("<option value='"+res[i]['id']+"'>"+res[i]['name']+"</option>");
			}
			}
		}
    });
});
</script>
</body>
</html>